//
//  SelectInviterHeaderView.m
//  PigMarket
//
//  Created by Felix on 2019/3/13.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "SelectInviterHeaderView.h"

@interface SelectInviterHeaderView ()

/**
 topView
 */
@property (nonatomic , strong) UIView *topView;

/**
 iconImageView
 */
@property (nonatomic , strong) UIImageView *iconImageView;

/**
 提示
 */
@property (nonatomic , strong) UILabel *tips;

@end

@implementation SelectInviterHeaderView

#pragma mark - init method
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self addSubview:self.topView];
    [self.topView addSubview:self.iconImageView];
    [self.topView addSubview:self.inviteCodeField];
    [self.topView addSubview:self.nextBtn];
    [self addSubview:self.tips];
}

- (void)initLayout {
    // 布局子控件
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(56);
    }];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.left.mas_equalTo(15);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-15);
        make.size.mas_equalTo(CGSizeMake(15, 15));
    }];
    [self.inviteCodeField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImageView.mas_right).offset(20);
        make.top.bottom.mas_equalTo(0);
        make.right.mas_equalTo(self.nextBtn.mas_left).offset(-10);
    }];
    [self.tips mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.topView.mas_bottom).offset(10);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.bottom.mas_equalTo(-10);
    }];
}

#pragma mark - getter and setter

- (UIView *)topView {
    if (!_topView) {
        _topView = [[UIView alloc] init];
        _topView.backgroundColor = [UIColor whiteColor];
    }
    return _topView;
}
- (UIImageView *)iconImageView {
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
        _iconImageView.image = [UIImage imageNamed:@"register_selectInviter_invitecode"];
    }
    return _iconImageView;
}
- (UITextField *)inviteCodeField {
    if (!_inviteCodeField) {
        _inviteCodeField = [[UITextField alloc] init];
        _inviteCodeField.placeholder = @"输入邀请码";
        _inviteCodeField.textColor = [UIColor textBlackColor];
        _inviteCodeField.font = [UIFont largerFont];
        _inviteCodeField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
        _inviteCodeField.keyboardType = UIKeyboardTypeNumberPad;
        _inviteCodeField.returnKeyType = UIReturnKeyNext;
    }
    return _inviteCodeField;
}
- (UIButton *)nextBtn {
    if (!_nextBtn) {
        _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _nextBtn.adjustsImageWhenHighlighted = NO;
        [_nextBtn setBackgroundImage:[UIImage imageNamed:@"address_selected_next"] forState:UIControlStateNormal];
    }
    return _nextBtn;
}
- (UILabel *)tips {
    if (!_tips) {
        _tips = [[UILabel alloc] init];
        _tips.textColor = [UIColor colorWithHexString:@"#969696"];
        _tips.font = [UIFont smallFont];
        _tips.text = @"如您没有邀请码，请在下方选择一个邀请人，能更好的为您引导。";
        _tips.numberOfLines = 0;
    }
    return _tips;
}

@end
